<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="ThemeBucket">
    <link rel="shortcut icon" href="#" type="image/png">

    <title>Dynamic Table</title>

    <!--dynamic table-->
    <link href="/public/js/advanced-datatable/css/demo_page.css" rel="stylesheet" />
    <link href="/public/js/advanced-datatable/css/demo_table.css" rel="stylesheet" />
    <link rel="stylesheet" href="/public/js/data-tables/DT_bootstrap.css" />
    <?php $this->load->view('library/header');?>
</head>

<body class="sticky-header">

<section>

    <?php $this->load->view('library/left');?>

    <!-- main content start-->
    <div class="main-content" >

        <?php $this->load->view('library/top');?>

        <!-- page heading start-->
        <div class="page-heading">
            <h3>
                产品列表
            </h3>
            <ul class="breadcrumb">
                <li>
                    <a href="#">Dashboard</a>
                </li>
                <li>
                    <a href="#">Data Tables</a>
                </li>
                <li class="active"> Dynamic Table </li>
            </ul>
        </div>
        <!-- page heading end-->

        <!--body wrapper start-->
        <div class="wrapper">
            <div class="row">
                <div class="col-sm-12">
                    <?php $this->load->view('library/search');?>
                    <section class="panel">
                        <div class="panel-body">

                            <div class="adv-table">
                                <table  class="display table table-bordered table-striped" id="dynamic-table">
                                    <thead>
                                    <tr>
                                        <th width="2%">#</th>
                                        <th width="3%">货架位名称</th>
                                        <th width="10%">添加时间</th>
                                        <th width="5%" class="hidden-phone">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <?php foreach ($shelves_list as $item): ?>
                                        <tr class="gradeX">
                                            <td><?php echo $item['sl_id'];?></td>
                                            <td><?php echo $item['sl_title'];?></td>
                                            <td><?php echo date('Y-m-d', $item['add_time']);?></td>
                                            <td class="hidden-phone">
                                                <a class="btn btn-xs btn-success" href="<?php echo base_url('GoodsSku/index') . "?sl_title={$item['sl_title']}";?>">查看产品</a>
                                                <a class="btn btn-xs btn-info" href="<?php echo base_url("GoodsSku/print_code/sl_title/{$item['sl_title']}");?>" target="_blank">打印条码</a>
                                                <a class="btn btn-xs btn-danger a-ajax" href="<?php echo base_url("GoodsSku/shelves_del/sl_id/{$item['sl_id']}");?>">删除</a>
                                            </td>
                                        </tr>
                                    <?php endforeach;?>
                                    </tbody>
                                </table>
                            </div>
                            <div class="row-fluid">
                                <div class="span6">
                                    <div class="dataTables_paginate paging_bootstrap pagination">
                                        <ul>
                                            <?php echo $pages;?>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </section>
                </div>
            </div>
        </div>
        <!--body wrapper end-->

        <!--footer section start-->
        <footer>
            2014 &copy; AdminEx by
        </footer>
        <!--footer section end-->


    </div>
    <!-- main content end-->
</section>

<?php $this->load->view('library/footer');?>

<script type="text/javascript">
    $('.input-type-multiple').on('click', function () {

        var url = $(this).attr('href');

        var sn = $(this).attr('data-no');

        swal({
            title: '库存校正 - ' + sn,
            html:
            '<input id="sku_number" placeholder="输入库存" class="swal2-input">' +
            '<input id="log_info" placeholder="输入原因" class="swal2-input">',
            showCancelButton: true,
            confirmButtonText: 'Submit',
            showLoaderOnConfirm: true,
            preConfirm: function preConfirm() {
                return $.post(url, {sku_number: $('#sku_number').val(), log_info: $('#log_info').val()}, function (data) {
                    return data;
                },'json');
            },
            allowOutsideClick: false
        }).then(function (result) {
            console.log(result);
            if (result.value) {
                var data = result.value;
                swal({
                    type: data.status,
                    title: data.info
                }).then(function(isConfirm) {
                    location.reload();
                });
            }
        });
        return false;
    });

    $('.a-ajax').click(function () {

        var url = $(this).attr('href');
        swal({
            title: '确定要删除吗?',
            type: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#3085d6',
            cancelButtonColor: '#d33',
            confirmButtonText: 'Yes, delete it!'
        }).then(function (result) {
            if (result.value) {
                $.get(url, {is_ajax: 1}, function (data) {
                    swal({
                        title: data.info,
                        text: '2秒后关闭',
                        type: data.status,
                        allowOutsideClick: false,
                        timer: data.stop ? data.stop : 1500,
                        showConfirmButton: false
                    }).then(function(isConfirm) {
                        location.reload();
                    });

                }, 'json');
            }
        })


        return false;
    });

</script>

<!--common scripts for all pages-->
<script src="/public/js/scripts.js"></script>

</body>
</html>
